/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.projet.entities;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Oussama
 */
@Entity
@Table(name = "details")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Details.findAll", query = "SELECT d FROM Details d"),
    @NamedQuery(name = "Details.findByIdCommandeIdProduit", query = "SELECT d FROM Details d WHERE d.idCommandeIdProduit = :idCommandeIdProduit"),
    @NamedQuery(name = "Details.findByDate", query = "SELECT d FROM Details d WHERE d.date = :date"),
    @NamedQuery(name = "Details.findByQuantite", query = "SELECT d FROM Details d WHERE d.quantite = :quantite")})
public class Details implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "id_commande__id_produit")
    private String idCommandeIdProduit;
    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    private Date date;
    @Column(name = "quantite")
    private BigInteger quantite;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "details")
    private List<ProduitCommande> produitCommandeList;

    public Details() {
    }

    public Details(String idCommandeIdProduit) {
        this.idCommandeIdProduit = idCommandeIdProduit;
    }

    public String getIdCommandeIdProduit() {
        return idCommandeIdProduit;
    }

    public void setIdCommandeIdProduit(String idCommandeIdProduit) {
        this.idCommandeIdProduit = idCommandeIdProduit;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public BigInteger getQuantite() {
        return quantite;
    }

    public void setQuantite(BigInteger quantite) {
        this.quantite = quantite;
    }

    @XmlTransient
    public List<ProduitCommande> getProduitCommandeList() {
        return produitCommandeList;
    }

    public void setProduitCommandeList(List<ProduitCommande> produitCommandeList) {
        this.produitCommandeList = produitCommandeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCommandeIdProduit != null ? idCommandeIdProduit.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Details)) {
            return false;
        }
        Details other = (Details) object;
        if ((this.idCommandeIdProduit == null && other.idCommandeIdProduit != null) || (this.idCommandeIdProduit != null && !this.idCommandeIdProduit.equals(other.idCommandeIdProduit))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.projet.entities.Details[ idCommandeIdProduit=" + idCommandeIdProduit + " ]";
    }
    
}
